package com.bml.architect.springboot.config;

import com.bml.architect.springboot.utils.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {

    @Bean
    public Queue topicQ1() {
        return new Queue(Constants.TOPICS_QUEUE1);
    }

    @Bean
    public Queue topicQ2() {
        return new Queue(Constants.TOPICS_QUEUE2);
    }

    @Bean
    public TopicExchange topicExchange() {

        return new TopicExchange(Constants.TOPICS_EXCHANGE);
    }

    @Bean
    public Binding topicQ1Binding() {
        return BindingBuilder.bind(topicQ1()).to(topicExchange()).with("t1.#");
    }

    @Bean
    public Binding topicQ2Binding() {
        return BindingBuilder.bind(topicQ2()).to(topicExchange()).with("t2.#");
    }
}
